package com.deyuanyun.pic.pipe.controller.vo;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.pipe.domain.Identification;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.util.ArrayList;
import java.util.List;

/**
 * 地面标识表
 */
public class IdentificationVO extends BaseVO<Identification> {

    // 管道名称
    private String pipeLineName;
    // 标识编号
    private String signNumber;
    // 标识类型
    private String signType;
    // 绝对距离(m)
    private String mileage;
    // 标识状态
    private String signStatus;
    // 链接计算结果表
    private String gisId;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getSignNumber() {
        return signNumber;
    }

    public void setSignNumber(String signNumber) {
        this.signNumber = signNumber;
    }

    public String getSignType() {
        return signType;
    }

    public void setSignType(String signType) {
        this.signType = signType;
    }

    public String getMileage() {
        return mileage;
    }

    public void setMileage(String mileage) {
        this.mileage = mileage;
    }

    public String getSignStatus() {
        return signStatus;
    }

    public void setSignStatus(String signStatus) {
        this.signStatus = signStatus;
    }

    public String getGisId() {
        return gisId;
    }

    public void setGisId(String gisId) {
        this.gisId = gisId;
    }

    public void fromDomain(Identification domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 标识编号
        this.signNumber = domain.getSignNumber();
        // 标识类型
        this.signType = CodeUtil.getName(domain.getSignType());
        // 绝对距离(m)
        this.mileage = NumberFormat.format(domain.getMileage(), NumberFormat.FMT_PLACES3);
        // 标识状态
        this.signStatus = CodeUtil.getName(domain.getSignStatus());
        // gis地址
        this.gisId = domain.getGisId();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordtime(), domain.getCreateRemark());
    }

    public Page<IdentificationVO> fromDomainList(Page<Identification> domainList) {
        Page<IdentificationVO> list = new Page<IdentificationVO>();
        for (Identification identification : domainList) {
            IdentificationVO identificationVO = new IdentificationVO();
            identificationVO.fromDomain(identification);
            list.add(identificationVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}